<template>
  <el-table :data="tableData" class="data_table">
    <el-table-column prop="company" label="客户名称" width="180">
    </el-table-column>
    <el-table-column prop="applicanter" label="申请人" width="180">
    </el-table-column>
    <el-table-column prop="type" label="申请类型">
    </el-table-column>
    <el-table-column prop="issuedTime" label="开始时间">
    </el-table-column>
    <el-table-column prop="expiryTime" label="结束时间">
    </el-table-column>
    <el-table-column prop="expiryTime" label="审批状态">
    </el-table-column>
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
      <template slot-scope="scope">
        <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="success(scope.row)"
        >同意</el-button>
        <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="fail(scope.row)"
        >拒绝</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import axios from "axios";

export default {
  name: "ListApply",
  data () {
    return {
      formData: {
        applicanter: undefined,
        company: undefined,
        field108: null,
        reason: undefined,
        version: undefined,
        macAddress: undefined,
        department: undefined,
        type: undefined,
        expiryTime: null,
        description: undefined,
        state: false,
      },
      tableData: [{
        company: '2016001',
        applicanter: '小明',
        type: '这是第一条数据'
      }, {
        company: '2016002',
        applicanter: '小明',
        type: '这是第二条数据'
      }, {
        company: '2016003',
        applicanter: '小明',
        type: '这是第三条数据'
      }, {
        company: '2016004',
        applicanter: '小明',
        type: '这是第四条数据'
      }, {
        company: '2016005',
        applicanter: '小明',
        type: '这是第五条数据'
      }]
    }
  },

  created() {
    this.getList();
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    getList() {
      this.loading = true;
      axios
          .post('api/license/listApplicantion',this.formData).then(response => {

            this.tableData = response.data.rows;
            // this.total = response.total;
            this.loading = false;
      });
    },
    success(row){
      console.log("success"+row.id);
      let param ={id:row.id,state: true};
      axios
          .post('api/license/dealApplicantion',param).then(response => {
        if(response.data.result=="ok"){
              console.log("success"+row.id);
              alert("审批通过");

            }
            // this.tableData = response.data.rows;
            // // this.total = response.total;
            // this.loading = false;
        this.getList();
      });
    },
    fail(row){
      console.log("fail"+row.id);
      let param ={id:row.id,state: false};
      axios
          .post('api/license/dealApplicantion',param).then(response => {
        if(response.data.result=="ok"){
          console.log("fail"+row.id);
          alert("已拒绝");

        }
        // this.tableData = response.data.rows;
        // // this.total = response.total;
        // this.loading = false;
        this.getList();
      });
    },
  }
}
</script>

<style scoped>

</style>
